function login() {
  let alert = document.getElementById("alert");
  alert.style.display = "none";
  let id = document.getElementById("id").value;
  let password = document.getElementById("password").value;
  let role = document.getElementById("role");
  role = role.options[role.selectedIndex].value;
  if (id === "" || password === "") {
    alert.innerHTML = "请输入ID和密码";
    alert.style.display = "block";
    return;
  }
  axios
    .post("login", {
      id: id,
      pwd: password,
      role: role,
    })
    .then(function (response) {
      console.log(response);
      let redirect = response.data.redirect;
      if (redirect == "undefined" || redirect == null || redirect == "") {
        alert.innerHTML = response.data.info;
        alert.style.display = "block";
        return;
      }
      window.location = response.data.redirect;
    })
    .catch(function (error) {
      console.log(error);
    });
}

